package com.docman.dao;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.ArrayList;

import com.docman.dbconnect.ConnectionManager;
import com.docman.domainmodel.UniversityBean;

public class UniversityDAO {
	static Connection currentCon = null;
	static ResultSet rs = null;
	
	public static ArrayList<UniversityBean> getUniversities() {
		ArrayList<UniversityBean> universities = new ArrayList<UniversityBean>();
		

		String query = "SELECT * FROM university";
		
		
		
		try{
			
			currentCon =ConnectionManager.getInstance().getConnection();
			Statement stmt  = currentCon.prepareStatement(query);
			
			rs= stmt.executeQuery(query);
			
			while(rs.next()){
				UniversityBean uni = new UniversityBean();
				
				uni.setUniversityName(rs.getString("uniName"));
				
				universities.add(uni);
				
			}
		
			rs.close();
			stmt.close();
		
		}
		catch(Exception e){
			
			System.out.println("Getting Universities Failed :"+e);
		}
		
	
		return universities;
	}

}
